/*
 * actiontable.c
 *
 *  Created on: 2009-5-25
 *      Author: hwg
 */

#include "../header/common.h"

int InitAction(actionLine * actionc, int statenum)
{
	actionc->statenum = statenum;
	return InitList_L(&actionc->table);
}

int getAction(actionLine * actionc, char ident ,elmAction *e)
{
	int i;
	ElemType node;
	if((i = searchAction_Sq(actionc->table, ident ,&node)))
	{
		*e = node.uniaction;
		return ok;
	}
	else
	{
		return error;
	}

}
int addAction(actionLine * actionc, elmAction e)
{
	int i;
	ElemType node;
	node.uniaction = e;
	if((i = ListInsertbutton_Sq(actionc->table,node)))
	{
		return ok;
	}
	else
	{
		return error;
	}

}
Status	searchAction_stl(actionLine L, char iden ,ElemType *f)
{
	ElemType e;
	int re;
	re = searchAction_Sq(L.table,iden,&e);
	*f = e;
	return re;
}

void printf_Action(LinkList L)
{
	LinkList p = L;
	p = p->next;
	printf("\n\tChar\tAct\tSnm\tgo\n");
	while(p != NULL)
	{
		printf("\n\t%c\t%c\t%d\t%d\n",p->data.uniaction.identyfy,p->data.uniaction.action,p->data.uniaction.number,p->data.uniaction.go);
		p = p->next;
	}

}
